package main

import "fmt"

/**
  闭包
 */

func main() {
	f := Addr(1)

	fmt.Println(f(1),f(2))

	f1,f2 := returnTwoVal(10)
	fmt.Println(f1(2),f2(5))

}

func Addr(a int) func(int) int {
	
	return func(b int) int {
		return a + b
	}
}

/**
  多个返回值
 */
func returnTwoVal(base int) (func(int) int,func(int) int){

	add := func(i int) int{
		return base + i
	}

	sub := func(j int) int{
		return base - j
	}

	return add,sub
}
